<?php
/**
 * Zend_Acl_Resource.
 *  
 * @author Nguyen Hai Ha
 * @version 1.0
 */

class Hanh_Controller_Acl_Resource extends Zend_Acl
{
	public function __construct()
    {
        
        /** Guest module */
		$this->add(new Zend_Acl_Resource('index'))
		     ->add(new Zend_Acl_Resource('news'))
		     ->add(new Zend_Acl_Resource('section'))
		     ->add(new Zend_Acl_Resource('search'));
		     
		/** Account module */
		$this->add(new Zend_Acl_Resource('account'))
			 ->add(new Zend_Acl_Resource('account:forgotpassword'))
			 ->add(new Zend_Acl_Resource('account:index'))
			 ->add(new Zend_Acl_Resource('account:signin'))
			 ->add(new Zend_Acl_Resource('account:signout'))			 
			 ->add(new Zend_Acl_Resource('account:register'));
		
		/** Error module */
		$this->add(new Zend_Acl_Resource('error'))
			 ->add(new Zend_Acl_Resource('error:error')); 
		
		/** Member module */
		$this->add(new Zend_Acl_Resource('member'))
			 ->add(new Zend_Acl_Resource('member:article'))
			 ->add(new Zend_Acl_Resource('member:commodity'))
			 ->add(new Zend_Acl_Resource('member:profile'))
			 ->add(new Zend_Acl_Resource('member:message'))
			 ->add(new Zend_Acl_Resource('member:money'))
			 ->add(new Zend_Acl_Resource('member:index'));
		    
		/** Administrator module */
		$this->add(new Zend_Acl_Resource('administrator'))
			 ->add(new Zend_Acl_Resource('administrator:profile'))
			 ->add(new Zend_Acl_Resource('administrator:article'))			 
			 ->add(new Zend_Acl_Resource('administrator:category'))
			 ->add(new Zend_Acl_Resource('administrator:commodity'))
			 ->add(new Zend_Acl_Resource('administrator:config'))
			 ->add(new Zend_Acl_Resource('administrator:member'))			 
			 ->add(new Zend_Acl_Resource('administrator:section'))
			 ->add(new Zend_Acl_Resource('administrator:status'))
			 ->add(new Zend_Acl_Resource('administrator:system'))
		     ->add(new Zend_Acl_Resource('administrator:index'));
		    		    
		/** Creating Roles */
		$this->addRole(new Zend_Acl_Role('guest'))
		     ->addRole(new Zend_Acl_Role('member'), 'guest')
		     ->addRole(new Zend_Acl_Role('editor'), 'member')
		     ->addRole(new Zend_Acl_Role('administrator'), 'member');
		    
		/** Creating permissions for guest*/
		$this->deny ('guest', 'administrator')
		     ->deny ('guest', 'member')
		     ->allow('guest', 'account:forgotpassword')
			 ->allow('guest', 'account:index')
			 ->allow('guest', 'account:register')
			 ->allow('guest', 'account:signin')
		     ->deny('guest', 'news')
		     ->deny('guest', 'search')
		     ->deny('guest', 'section')
		     ->deny('guest', 'index');
		    
		/** Creating permissions for member*/
		$this->deny ('member', 'account:index')
			 ->deny ('member', 'account:signin')
			 ->deny ('member', 'account:register')
			 ->deny ('member', 'administrator')			 
			 ->allow('member', 'account:signout')			 
			 ->allow('member', 'member')
			 ->allow('member', 'member:article')
			 ->allow('member', 'member:commodity')
			 ->allow('member', 'member:index')
			 ->allow('member', 'member:profile')
			 ->allow('member', 'member:message')
			 ->allow('member', 'member:money');
			 
		/** Creating permissions for administrator*/
		$this->allow('editor')
			 ->deny('editor', 'administrator:member')
			 ->deny('editor', 'administrator:system');
			 
		/** Creating permissions for administrator*/
		$this->allow('administrator');
		
    }//End function.    
}//End class.